<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<%@ include file="../../common/jsp/sheetHeader.jsp" %>
<script>
	$(document).ready(function() {
		//sheet 초기화  
		var cfg = {
		    Chart : {
				Animation : true,
		        PlotBackgroundColor : "#FAFAFA",
				PlotBorderColor:"#A9AEB1",
		        PlotBorderWidth:0.5,
				BackgroundColor:{
					LinearGradient : [0,0,100,500],
					Stops : [
						[0, "#D7E1F3"],
						[1, "#FFFFFF"]
					]
				},
				BorderColor : "#84888B",
				
// 				Type : "column",
		        Style : {
		            FontSize : "20px"
		        }		
		    },
			Credits : {
				Enabled:false
			},
			
			Colors : ["#7AAAEE","#F06F3E","#AAEE6A","#F0E150","#5DA0A9","#75738B"],
			
		    Legend : {
				Enabled:false
		    },
			
		    YAxis : {
		        LineColor : "#7F7F7F",
		        TickInterval : 50,
				GridLineDashStyle : "solid",
		        GridLineWidth : 1,
		        GridLineColor : "#C4C9CD",
		        LineWidth : 1,
		        Title : {
		            Text : ""
		        }
		    }
		}
		
		myChart.SetOptions(cfg);
		myChart.Draw();
		myChart.DoSearch("../data/chartdata_pie.xml");
		
		myChartDraw();
		
	});
	
	function myChartDraw() {
		var Type = $("#pieCombo").val();
		myChart.RemoveAll();
		
		switch(Type){
		case "PIE":			
			myChart.SetBaseOptions({
					Type:"pie"
				},1);
				
				myChart.SetPlotOptions({
					Series:{
						DataLabels:{
							Enabled:true,
							Align:"center",
							Color : "#333333",
							Formatter:function(){
								return this.point.name + ': ' + this.y ;
							}
						}
					},
					Pie:{
						InnerSize:0,
						SlicedOffset:20,
						AllowPointSelect:true
					}
				},1);
				myChart.DoSearch("../data/chartdata_pie.xml");
			break;

		case "PIE_Sliced":			
			myChart.SetBaseOptions({
					Type:"pie"
				},1);
				
				myChart.SetPlotOptions({
					Series:{
						DataLabels:{
							Enabled:true,
							Align:"center",
							Color : "#333333",
							Formatter:function(){
								return this.point.name + ': ' + this.y ;
							}
						}
					},
					Pie:{
						InnerSize:0,
						SlicedOffset:20,
						AllowPointSelect:true
					}
				},1);
				myChart.DoSearch("../data/chartdata_pie_sliced.xml");
			break;

		case "PIE_InnerSize":			
			myChart.SetBaseOptions({
					Type:"pie"
				},1);
				
				myChart.SetPlotOptions({
					Series:{
						DataLabels:{
							Enabled:true,
							Align:"center",
							Color : "#333333",
							Formatter:function(){
								return this.point.name + ': ' + this.y ;
							}
						}
					},
					Pie:{
						InnerSize:100,
						SlicedOffset:20,
						AllowPointSelect:true
					}
				},1);
				myChart.DoSearch("../data/chartdata_pie.xml");
			break;

		case "PIE_Sliced_InnerSize":
			myChart.SetBaseOptions({
					Type:"pie"
				},1);
				
				myChart.SetPlotOptions({
					Series:{
						DataLabels:{
							Enabled:true,
							Align:"center",
							Color : "#333333",
							Formatter:function(){
								return this.point.name + ': ' + this.y ;
							}
						}
					},
					Pie:{
						InnerSize:100,
						SlicedOffset:20,
						AllowPointSelect:true
					}
				},1);
			myChart.DoSearch("../data/chartdata_pie_sliced.xml");
			break;
	
		case "GAUGE":
			myChart.SetDefaultSeriesType(IBChartType.GAUGE);
			myChart.SetAngle({StartAngle:-150,EndAngle:150});
			myChart.SetPane([
			{BorderWidth:1,BorderColor:'#ff0000',BackgroundColor:'#ff8888',InnerRadius:'10%',OuterRadius:'20%'}
			,{BorderWidth:10,BorderColor:'#bbbbff',BackgroundColor:'#eeeeff',InnerRadius:'30%',OuterRadius:'100%'}
			]);

			myChart.GetYAxis().SetMin(0);
			myChart.GetYAxis().SetMax(180);
			myChart.GetYAxis().SetTickInterval(10);
			
			myChart.SetLegend({Enabled:false});

			var series = myChart.CreateSeries();
			series.AddPoints([{ X:0, Y: '120',BorderColor:'#ff8888'},{ X:1, Y: '65', DialRadius:'30%', DialWidth:'10',DialLength:'50%',DialRearLength:'40%'}]);
			myChart.AddSeries(series);
			
			break;
		}
		
		myChart.Draw();
	}
	
</script>
<title>파이 차트 예제</title>
</head>
<body>
<div id="main">
	<%@ include file="../../common/jsp/chartNavi.jsp" %>	
	<div id="title">파이 차트 예제</div>
	<div id="desc">
		원 형태의 차트<br>
	</div>

	<div id="functionArea">
	<select class="chartCombo" id="pieCombo" onchange="myChartDraw()">
		<option value="PIE">파이</option> 
		<option value="PIE_Sliced">쪼개진 파이</option> 
		<option value="PIE_InnerSize">도넛</option> 
		<option value="PIE_Sliced_InnerSize">쪼개진 도넛</option> 
	</select>
	</div>
	
	<div id="viewArea">
		<script type="text/javascript">
			createIBChart("myChart", "1000px", "300px");
		</script>
	</div>
</div>
</body>
</html>